using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Framework.Library.Utilities;
using Framework.Module.CMS.Library.Definitions;
using Framework.Library;
using Framework.Module.CMS.Library.Distributions;
using Framework.Module.CMS.Library;
using Framework.Library.Components;
using Framework.Module.CMS.Library.Zones;

namespace Framework.Module.CMS.Web.HomePage
{
    public partial class LeftNewNews : CMSWebControl
    {
        public int zoneid;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            zoneid = ConvertUtility.ToInt32(Portal[Constants.CMS_TinMoiNhan + AppEnv.GetLanguage()]);
            ZoneInfo info = ZoneController.GetZone(zoneid);
            hplCaption.Text = info.Zone_Name;
            
            hplMore.NavigateUrl = BuildUrlByZone(zoneid, info.Portal_TabControlID);
            DataTable focus = DistributionController.GetDistributedContents(zoneid,1, (int)CMSDistributionRank.Special);
            if (focus.Rows.Count > 0)
            {
                int distid = ConvertUtility.ToInt32(focus.Rows[0]["Distribution_ID"]);
                hplspecial.Text = focus.Rows[0]["Content_Headline"].ToString();
                hplspecial.NavigateUrl = BuildUrlByDistId(distid, zoneid);

                DataTable tblist = DistributionController.GetDistributedContents(zoneid, 6, (int)CMSDistributionRank.Special);

                rptLastestNews.DataSource = tblist;
                rptLastestNews.DataBind();
            }
        }
        protected void rptLastestNews_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView currow = (DataRowView)e.Item.DataItem;
                HyperLink hplTitle = (HyperLink)e.Item.FindControl("hplTitle");
                hplTitle.Text = ConvertUtility.ToString(currow["Content_Headline"]);
                hplTitle.NavigateUrl = BuildUrlByDistId((int)currow["Content_ID"], ConvertUtility.ToInt32(Portal[Constants.CMS_TinMoiNhan + AppEnv.GetLanguage()]));
            }
        }
    }
}